package com.software.library_conquer;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

/**
 * Created by C.C on 2015/4/9.
 */
public class DrawerView implements View.OnClickListener {
    private final Activity activity;
    SlidingMenu slidingMenu;
    private TextView night_text;
    private RelativeLayout setting;
    public DrawerView(Activity activity){
        this.activity = activity;
    }

    public SlidingMenu initSlidingMenu() {
        slidingMenu = new SlidingMenu(activity);
        slidingMenu.setMode(SlidingMenu.LEFT);//设置左右滑菜单
        slidingMenu.setTouchModeAbove(SlidingMenu.SLIDING_WINDOW);//设置要使菜单滑动，触碰屏幕的范围
//		localSlidingMenu.setTouchModeBehind(SlidingMenu.SLIDING_CONTENT);//设置了这个会获取不到菜单里面的焦点，所以先注释掉
        slidingMenu.setShadowWidthRes(R.dimen.shadow_width);//设置阴影图片的宽度
        slidingMenu.setShadowDrawable(R.drawable.shadow);//设置阴影图片
        slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);//SlidingMenu划出时主页面显示的剩余宽度
        slidingMenu.setFadeDegree(0.35F);//SlidingMenu滑动时的渐变程度
        slidingMenu.attachToActivity(activity, SlidingMenu.LEFT);//使SlidingMenu附加在Activity右边
//		localSlidingMenu.setBehindWidthRes(R.dimen.left_drawer_avatar_size);//设置SlidingMenu菜单的宽度
        slidingMenu.setMenu(R.layout.left_drawer_fragment);//设置menu的布局文件
//		localSlidingMenu.toggle();//动态判断自动关闭或开启SlidingMenu
//        slidingMenu.setSecondaryMenu(R.layout.profile_drawer_right);
//        slidingMenu.setSecondaryShadowDrawable(R.drawable.shadowright);
        slidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
            public void onOpened() {

            }
        });
        slidingMenu.setOnClosedListener(new SlidingMenu.OnClosedListener() {

            @Override
            public void onClosed() {
                // TODO Auto-generated method stub

            }
        });
        initView();
        return slidingMenu;
    }
    private void initView(){

        RelativeLayout site = (RelativeLayout)activity.findViewById(R.id.switch_btn);
        site.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(activity, MyActivity.class);
                activity.startActivity(intent);
                activity.finish();
            }
        });

        RelativeLayout achivement = (RelativeLayout)activity.findViewById(R.id.achievement_btn);
        achivement.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(activity, AchievementActivity.class);
                activity.startActivity(intent);
                activity.finish();
            }
        });
    }
    @Override
    public void onClick(View v) {
        Log.d("cc", v.getId()+"");
        switch (v.getId()){
            case R.id.switch_btn:
                break;
            default:
                break;
        }
    }


}
